<template>
	<view>
		<!-- <u-navbar :is-back="true" :is-fixed="true" title="产品详情"></u-navbar> -->
		<u-field v-model="newlist.enterpriseName" :border-bottom="false" label-width="170" label="下游企业名称"
			:disabled="true" input-align="right" :field-style="placeholderStyle">
		</u-field>
		<u-field v-model="newlist.title" :border-bottom="false" label="需求标题" label-width="180" :disabled="true"
			input-align="right" :field-style="placeholderStyle"></u-field>

		<u-field v-model="newlist.productName" :border-bottom="false" label="产品名称" label-width="180" :disabled="true"
			input-align="right" :field-style="placeholderStyle"></u-field>

		<u-field v-model="newlist.legalRepresentative" :border-bottom="false" :disabled="true" label="联系人"
			label-width="140" input-align="right" :field-style="placeholderStyle"></u-field>

		<!-- <u-field v-model="newlist.number" :border-bottom="false" :disabled="true" label-width="180" label="需求数量"
			input-align="right" :field-style="placeholderStyle">
			</u-field> -->
			<view class="dfex pl-3 pr-3 lineHight-3">
				<view>需求数量</view>
				<view class="dfel text-999999">
					<view>{{newlist.number}}</view>
					<view>
						{{newlist.productSpecsText}}
					</view>
				</view>
			</view>
           
		<!-- <u-field v-model="newlist.productSpecs" :border-bottom="false" :disabled="true" label="需求规格" input-align="right"
			:field-style="placeholderStyle"></u-field> -->
		<u-field v-model="newlist.price" :border-bottom="false" :disabled="true" label-width="180" label="需求价格(元)" input-align="right"
			:field-style="placeholderStyle"></u-field>
		<u-field v-model="newlist.endTime" :border-bottom="false" :disabled="true" label="截止日期" input-align="right"
			:field-style="placeholderStyle"></u-field>
		<view class="flex-center fixed-bottoms">
			<view class="bg-FFC251 rounded-circle py-2 pl-5 pr-5 text-white font-14" @click="makePhoneCall(newlist.phone)">电话咨询</view>
			<view class="bg-78AB06 rounded-circle py-2 pl-5 pr-5 text-white font-14"
				@click="addProductServe(newlist.id)">使用服务
			</view>
		</view>
	</view>
</template>

<script>
	import $H from '@/common/free-lib/request.js';
	import ferrButton from "@/components/free-ui/ferr-button.vue";
	export default {
		components: {
			ferrButton,
		},
		data() {
			return {

				newlist: {},
				placeholderStyle: {
					color: '#999'
				},
			}
		},
		computed: {

		},
		onLoad(options) {
			const id = options.id;
			this.NewListDetail(id)
		},
		methods: {
			NewListDetail(id) {
				$H.get('/down/downMarketDemand/queryById', {
					id: id
				}, {}).then(res => {
					this.newlist = res.result
					this.phone = res.result.phone
				}).catch(error => {
					uni.showToast({
						title: "网络错误，请稍后再试",
						icon: 'none'
					});
				});
			},
			makePhoneCall(phone) {
				uni.showModal({
					title: '拨打电话',
					content: '确定要拨打电话吗？',
					success: (res) => {
						if (res.confirm) {
							this.doMakePhoneCall(phone);
						}
					}
				});
			},
			doMakePhoneCall(phone) {
				uni.makePhoneCall({
					phoneNumber: phone
				});
			},
			addProductServe(id) {
				uni.showModal({
					title: '使用服务',
					content: '是否确认发起下游需求服务？',
					success: (res) => {
						if (res.confirm) {
							// 用户点击了确认按钮，执行请求操作
							$H.post('/down/downServiceOrder/agriculture/addDemandServe', {
									downMarketDemandId: id
								}, {
									header: {
										'Content-Type': 'application/x-www-form-urlencoded'
									}
								})
								.then(res => {
									// 请求成功处理逻辑
									uni.showToast({
										title: res.message,
										icon: 'success'
									});
									setTimeout(() => {
										uni.switchTab({
											url: '/pages/tabbar/order/index'
										});
									}, 3000);
								})
								.catch(error => {
									// 请求失败处理逻辑
									uni.showToast({
										title: '网络错误，请稍后再试',
										icon: 'none'
									});
								});
						} else if (res.cancel) {
							// 用户点击了取消按钮，不执行任何操作
						}
					}
				});
			}


		}
	}
</script>

<style>
</style>